<template>
  <section>
    <el-form label-width="60px" size="mini">
      <el-form-item label="选择：">
        <el-select size="mini" v-model="activity.actionData.actionData" value-key="id" placeholder="请选择活动内容">
          <el-option v-for="p in actionList" :key="p.id" :value="p" :label="p.name"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="名称：">{{activity.actionData.actionData.name}}</el-form-item>
      <el-form-item label="编码：">{{activity.actionData.actionData.code}}</el-form-item>
      <el-form-item label="内容：">
        <send-coupon v-if="activity.actionData.actionData.code === 'send_coupon'" :row="activity.actionData.actionData" :activity="activity"></send-coupon>
        <shopping v-else-if="activity.actionData.actionData.code === 'shopping'" :activity="activity" ></shopping>
        <qa v-else-if="activity.actionData.actionData.code === 'qa'" :row="activity.actionData.actionData" :activity="activity"></qa>
        <shopping v-else-if="activity.actionData.actionData.code === 'examine'" :activity="activity" ></shopping>
        <detection v-else-if="activity.actionData.actionData.code === 'detection'" :row="activity.actionData.actionData" :activity="activity" ></detection>
      </el-form-item>
    </el-form>
  </section>
</template>

<script>
  import detection from './actionModule/detection'
  import qa from './actionModule/qa'
  import sendCoupon from './actionModule/sendCoupon'
  import shopping from './actionModule/shopping'
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler'
  export default {
    name: "actAction",
    components: {sendCoupon,shopping,qa,detection},
    props: ['activity'],
    data(){
      return{
        actionList:[],
      }
    },
    created(){
      console.log('看活动行为喽~',this.activity)
      if(!this.activity.actionData.actionData){
        Vue.set(this.activity.actionData,'actionData',{})
      }
      this.getActivityActionList()
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      getActivityActionList(pageNo){
        this.fetch({name:"getActivityActionList",data:{page:pageNo?pageNo:0}})
          .then(res=>{
            console.log('活动行为列表----------',res)
            this.actionList=res.content
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
    }
  }
</script>

<style scoped>

</style>
